/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.appleframework.utils;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import org.apache.commons.io.IOUtils;
import org.appleframework.Apple;

/**
 * IO
 * @author zhujg
 */
public class IO {

  public static Properties readUtf8Properties(InputStream is) throws IOException{
    Properties properties = new Properties();
    properties.load(is);
    for(Object key : properties.keySet()){
      String value = properties.getProperty(key.toString());
      properties.put(key.toString(), new String(value.getBytes(),"utf-8"));
    }
    is.close();
    return properties;
  }

  public static String readContentToString(InputStream is) throws IOException{
     String content = IOUtils.toString(is,Apple.encode);
     is.close();
     return content;
  }
}
